package utils.astar
{
	
	/**
	 * 地图模型
	 */	
	public class MapTileModel implements IMapTileModel
	{
		private var m_map : Array;
		public var tileWidth:int
		public var tileHeight:int
		public var tileValue:int=0;//在地图中为tileValue时不可行走
		public function MapTileModel(tileWidth:int=0,tileHeight:int=0)
		{
		   this.tileWidth=	tileWidth;
		   this.tileHeight= tileHeight;
		}
		public function destroy():void{
		   m_map=null;
		}
		public function get map() : Array
		{
			return this.m_map;
		}
		public function set map(p_value : Array) : void
		{
			this.m_map = p_value;
		}
		public function getMapHeight():Number{
		   
		   return tileHeight;//m_map[0].length;
		}
		public function getMapWidth():Number{
		
		  return tileWidth;//m_map.length;
		}
		/**
		 * 是否为障碍
		 * @param p_startX	始点X坐标
		 * @param p_startY	始点Y坐标
		 * @param p_endX	终点X坐标
		 * @param p_endY	终点Y坐标
		 * @return 0为障碍 1为通路
		 */
		public function isBlock(p_startX : int, p_startY : int, p_endX : int, p_endY : int) : int
		{
			//var mapWidth : int = this.m_map.length;
			//if(m_map[0]==null) return 0;
			//var mapHeight : int = this.m_map[0].length;
			
			if (p_endX < 0 || p_endX == tileWidth || p_endY < 0 || p_endY == tileHeight)
			{
				return 0;
			}
			if(this.m_map[p_endX]==null){
				return 0;
			}
			return this.m_map[p_endX][p_endY]==tileValue?0:1
		}
	}
}